# encoding: UTF-8

class Admin::RolesController < ApplicationController

  before_filter :user_signed_in?
  
  def index
    @roles = Role.all
    set_seo_meta '职业介绍'
  end

  def new
    set_seo_meta '职业介绍添加'
  end

  def create
    @role = Role.new(params[:session])
    if @role.save
      redirect_to roles_path, notice: '新增成功'
    else
      redirect_referrer_or_default
    end  
  end

  def edit
    @role = Role.find(params[:id])
    set_seo_meta '职业介绍修改'
  end

  def update
    @role = Role.find(params[:id])
    if @role.update_attributes(params[:session])
      redirect_to roles_path, notice: '修改成功'
    else
      redirect_referrer_or_defautl default
    end
  end

  def destroy
    if Role.delete(params[:id])
      redirect_to roles_path, notice: '删除成功'
    else
      redirect_referrer_or_default default
    end  
  end

end
